package mobile.pubcrawler;

import mobile.pubcrawler.ui.*;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;


public final class PubCrawlerUI extends Activity {
    /** Called when the activity is first created. */
    private static PubCrawlerUI instance;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        instance = this;
        
        GPSManager.init(this.getApplicationContext());
        Filter.getInstance().loadFilterSettings(this);
        
        startMainUI();
    }
    
	public synchronized static PubCrawlerUI getInstance(){
		 if (instance == null) {
	            instance = new PubCrawlerUI();
	        }
	        return instance;
	}
	
    public void startMainUI(){
      	Intent intent = new Intent(this, MainUI.class);
    	startActivity(intent);
    }

    public void startCurrentTourUI(){
      	Intent intent = new Intent(this, CurrentTour.class);
    	startActivity(intent);
    }
    
    public void startFacebookUI(){
    	Intent intent = new Intent(this, Facebook.class);
    	startActivity(intent);
    }
    
    public void startCurrentPubUI(int position){
    	Intent intent = new Intent(this, CurrentPub.class);
    	intent.putExtra("position", position);
    	startActivity(intent);
    }

    public void startSettingsUI(){
    	Intent intent = new Intent(this, Settings.class);
    	startActivity(intent); 
    }
    
    public void startNextPubUI(){
      	Intent intent = new Intent(this, NextPub.class);
    	startActivity(intent); 
    }
    
    public void startSearchPubUI(){
    	Intent intent = new Intent(this, SearchPub.class);
    	startActivity(intent);    
    }
    
    public void startPubDetails(int position){
    	Intent intent = new Intent(this, PubDetails.class);
    	intent.putExtra("position", position);
    	startActivity(intent);    
    }
    
    public void startEditSmsUI(){
     	Intent intent = new Intent(this, EditSMS.class);
     	startActivity(intent);   
     }
    
    public void startStartLocationUI() {
     	Intent intent = new Intent(this, mobile.pubcrawler.ui.StartLocation.class);
     	startActivity(intent);   
     }
        
 // ------------------- Public Button listeners --------------------       
    public OnClickListener startFbButtonListener =  new OnClickListener(){
    	public void onClick(View v) { 
    		//Intent intent = new Intent(this,MainActivity.class);
            //startActivity(intent);
    		startFacebookUI();
        } 
    };
    
    public OnItemClickListener onClickPubListener = new OnItemClickListener(){
    	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    		//startRecipeEditor((int)id);
    	}   	
    };

	public int getImageResource(String category) {
		// Pubs, Cafe, Restaurant, Club, Biergarten, Cocktailbar
		if (category.equalsIgnoreCase("Pubs")) return R.drawable.pub_klein;
		if (category.equalsIgnoreCase("Cafe")) return R.drawable.coffee_klein;
		if (category.equalsIgnoreCase("Restaurant")) return R.drawable.restaurant_klein;
		if (category.equalsIgnoreCase("Club")) return R.drawable.club_klein;
		if (category.equalsIgnoreCase("Biergarten")) return R.drawable.beer_klein_neu;
		if (category.equalsIgnoreCase("Cocktailbar")) return R.drawable.cocktail_red_klein;
		return 0;
	}
}